// path模块
let path= require('path');
// 1.parse 解析路径，把路径解析成一个对象
console.log(path.parse('./src/a.js'));//{ root: '', dir: './src', base: 'a.js', ext: '.js', name: 'a' }
// // root:根路径;dir:当前路径;base:文件名（带后缀）;ext:后缀;name:文件名（不带后缀）;

console.log(path.extname('./src/a.js'));//.js
console.log(path.basename('./src/a.js'));//a.js


// 2.format 格式化 把对象形式的路径转成字符串的路径
let obj={ root: '', dir: './src', base: 'a.js', ext: '.js', name: 'a' };
console.log(path.format(obj));//./src\a.js

// 3.join 拼接路径
console.log(path.join('./src','d.js'));//src\d.js

// 4.resolve 拼接路径(绝对路径)
console.log(path.resolve('./src','c.js'));//E:\workspace高级Node\1910B高级Node\Exercise\day01\path模块\src\c.js

// 5.relative 拼接路径(相对路径)
console.log(path.relative('./src','a.js'));//..\a.js


// 6.__dirname process.cwd() 获取绝对路径的俩种方法
console.log(__dirname);//E:\workspace高级Node\1910B高级Node\Exercise\day01\path模块
console.log(process.cwd());//E:\workspace高级Node\1910B高级Node\Exercise\day01\path模块

//拼接
console.log(path.join( process.cwd(), './src'));//E:\workspace高级Node\1910B高级Node\Exercise\day01\path模块\src